package cn.flightcloud.boot;

import javax.sql.DataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AppConfig {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(AppConfig.class);

	@Bean
	@ConfigurationProperties(prefix = "spring.datasource")
	public DataSource createDataSource(DataSourceProperties properties) {
		LOGGER.info("init datasource");
		return properties.initializeDataSourceBuilder().build();
	}
}
